<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
	<xsl:template match="//foods">
		<group>
			<xsl:for-each-group select="//food" group-by="@course"><xsl:sort select="@course"/>
				<food>
					<xsl:attribute name="cost"><xsl:value-of select="sum(current-group()/@cost)"/></xsl:attribute>
					<xsl:attribute name="course"><xsl:value-of select="@course"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="current-group()/@name"/></xsl:attribute>
				</food>
			</xsl:for-each-group>
		</group>
	</xsl:template>
</xsl:stylesheet>